Design issues.md (2166B)
1 +++ 2 title = 'Design issues' 3 +++ 4 # Design issues 5 ## Allocation policies: 6 7 - local allocation: 8 - replaces only pages of current process 9 - assumes static process memory allocation size 10 - problems: 11 - growing *working set* leads to *trashing* 12 - shrinking working set leads to wasted memory 13 - global allocation: 14 - replaces pages owned by any process 15 - strategies: 16 - treat every global page equally, or prioritize 17 - dynamic memory balancing using working set size estimation 18 - selectively swap out processes, i.e. hurt process efficiency since it's not as important (or OOM kill) 19 20 ## Working set model: 21 22 - working set estimation: 23 - aging-based 24 - scanning-based: like aging, but without temporal dimension. divide time in discrete slots, scan all reference bits in page table entries, decide how many slots 25 - active lists (e.g. WSCLOCK): amount of pages in working set is known, want to decide which set of pages is in working set. active list of n elements (size of working set) which contains active pages 26 - applications: memory prepaging, page replacement, checkpoint-restore, live migration 27 - working set size estimation: 28 - sampling-based 29 - monitoring-based (e.g. page fault freq) 30 - Miss Rate Curves (MRC) 31 - applications: dynamic memory balancing, garbage collection, WS estimation 32 33 ## Cleaning policy: 34 35 - paging works well if there are a lot of free pages 36 - direct reclaim: when you have the need to allocate new page, you directly reclaim an existing page 37 - indirect reclaim: paging daemon sleeps and then evict pages if free pages are in short supply (don't wait until the last minute) 38 - another way is to leave them in memory, easy reuse 39 40 ## Virtual memory interface: 41 42 - allocator interface: malloc family, mmap family 43 - memory-mapped files 44 - treat files as memory objects for faster IO 45 - facilitate code sharing for programs/shared libs 46 - copy-on-write semantics 47 - lazy copying for fork(), deduplication, checkpointing, etc. 48 - shared memory 49 - MAP_SHARED mappings, key-based, file-based 50 - distributed shared memory 51 - shared memory semantics over network